def add(n1, n2):
    return n1 + n2


result = add(1, 2)
print(result)

add = lambda x, y: x + y
result = add(2, 3)
print(result)

func = lambda x: x ** 2 if x > 3 else x ** 3
print(func(4))


def mySorted(obj, key=None, reverse=False):
    newStus = []
    for s in students:
        for n in newStus:
            if key:
                if key(s) < key(n):
                    idx = newStus.index(n)
                    newStus.insert(idx, s)
                    break
            else:
                if s < n:
                    idx = newStus.index(n)
                    newStus.insert(idx, s)
                    break
        else:
            newStus.append(s)

    return newStus if reverse else newStus[::-1]


students = [1, 4, 2, 6, 7, 8, 4, 3, 3]
students = mySorted(students, reverse=False)
print(students)
